﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;

namespace AssetAllocationSystem.Tests.RepositoriesFixtures
{
    public class FixtureBase
    {
        private static bool IsDataCalled = false;
        private static ISession session;

        public static ISessionFactory CreateSessionFactory()
        {
            return
                Fluently
                .Configure()
                .Database(MsSqlConfiguration.MsSql2008.ConnectionString("Password=compaq1-2;Persist Security Info=True;User ID=sa;Initial Catalog=AssetsAllocationSystem;Data Source=DAMAYANTI-PC"))
                .Mappings(a => a.FluentMappings.AddFromAssembly(Assembly.Load("AssetAllocationSystem")))
                .BuildSessionFactory();
        }

        public static ISession CreateSession()
        {
            ISessionFactory sessionFactory = CreateSessionFactory();
            return sessionFactory.OpenSession();
        }
    }
}
